//
//  SCHomeSearchView.m
//  Mutal
//
//  Created by TonyStart on 16/10/18.
//  Copyright © 2016年 com.wx. All rights reserved.
//

#import "SCHomeSearchView.h"

@interface SCHomeSearchView()



@end

@implementation SCHomeSearchView

-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        [self setupUI];
    }
    return self;
}
-(UIImageView *)leftImgView{
    if (!_leftImgView) {
        
        CGFloat imgW = 20;
        
        
        _leftImgView = [[UIImageView alloc] initWithFrame:CGRectMake(10, (self.bounds.size.height - imgW)/2, imgW, imgW) ];
       
        
        _leftImgView.image = [UIImage imageNamed:@"放大镜"];

    }
    return _leftImgView;
}

-(UITextField *)searchField{
    if (!_searchField) {
        _searchField = [[UITextField alloc] initWithFrame:CGRectMake(CGRectGetMaxX(self.leftImgView.frame)+5, 0, self.bounds.size.width - CGRectGetWidth(self.leftImgView.frame) - 10, self.bounds.size.height)];
       
        _searchField.clearButtonMode = UITextFieldViewModeWhileEditing;
    }
    return _searchField;
}

-(void)setupUI{
    self.layer.cornerRadius = self.frame.size.height/2;
    self.layer.masksToBounds = YES;
    self.backgroundColor = [UIColor whiteColor];
    [self addSubview:self.leftImgView];
    [self addSubview:self.searchField];

}
@end
